from django.db import models

class Admin(models.Model):
    """管理员"""
    username = models.CharField(verbose_name='用户名', max_length=32)
    password = models.CharField(verbose_name='密码', max_length=32)
class Department(models.Model):

    """部门表"""
    title = models.CharField(max_length=32, verbose_name='部门标题')

    def __str__(self):
        return self.title

class UserInfo(models.Model):
    """员工表"""
    name = models.CharField(max_length=64, verbose_name='员工姓名')
    password = models.CharField(max_length=64, verbose_name='工号密码')
    age = models.IntegerField(verbose_name='员工年龄')
    salary = models.DecimalField(verbose_name='员工薪资', max_digits=10, decimal_places=2)
    join_date = models.DateField(verbose_name='入职时间')

    # 外键约束
    # -to,与指定的表关联
    # -to_fields 与表中的那一列关联
    depart = models.ForeignKey(verbose_name='部门', to='Department', to_field='id', on_delete=models.DO_NOTHING)

    gender_chioce = (
        (1, '男'),
        (2, '女'),
    )

    gender = models.SmallIntegerField(verbose_name='性别', choices=gender_chioce, default=1)

class PrettyNumbers(models.Model):
    """号码表"""
    mobile = models.CharField(verbose_name='手机号', max_length=11)
    price = models.IntegerField(verbose_name='价格',default=0)
    level_choices = (
        (1, '1级别'),
        (2, '2级别'),
        (3, '3级别'),
        (4, '4级别')
    )
    level = models.SmallIntegerField(verbose_name='级别', choices=level_choices, default=1)

    status_choices = (
        (1, '占用'),
        (2, '未占用')
    )
    status = models.SmallIntegerField(verbose_name='状态',choices=status_choices, default=2)

class Task(models.Model):
    """ 任务 """
    level_choices = (
        (1, "紧急"),
        (2, "重要"),
        (3, "不紧急"),
    )
    level = models.SmallIntegerField(verbose_name="级别", choices=level_choices, default=1)
    title = models.CharField(verbose_name="标题", max_length=32)
    detail = models.TextField(verbose_name="详细信息")
    user = models.ForeignKey(verbose_name="负责人", to="Admin", on_delete=models.CASCADE)





